#include <iostream>
#include <fstream>
#include <vector>
#include <unordered_set>
#include "hnsw.hpp"
#include "vecs_io.hpp"
#include "ground_truth.hpp"
#include "time_memory.hpp"

using namespace std;
using namespace MultipleHNSW;


int main() {
    const char *dataset_name = "siftsmall";
    const int M = 40;
    const int ef_construction = 100;
    const int random_seed = 100;
    const int n_index = 1;

    const int ef_search_config[3] = {10, 5, 50}; //start, stride, iter

    int n_query, top_k, n_base, data_dim;
    top_k = 10;

    vector<float *> data = read_data(dataset_name, n_query, top_k, n_base, data_dim);
    float *base = data[0];
    float *query = data[1];
    int *gnd = (int *) data[2];

    printf("M %d, efConstruction %d, n_index %d\n", M, ef_construction, n_index);

    //build index
    vector<int> indexing_time_l(n_index);
    TimeRecord total_insert_record;
    printf("building index\n");
    vector<int> label_l(n_base);
    for (int i = 0; i < n_base; i++) {
        label_l[i] = i;
    }
    std::shuffle(label_l.begin(), label_l.end(),
                 default_random_engine(random_seed));

    HNSW hnsw(data_dim, n_base, M, ef_construction, random_seed);
    hnsw.insert(base, label_l);
    hnsw.test_graph();

    return 0;
}